<html>

<head>
    <title>课程表</title>
    <script src="./js/jquery-3.7.1.js"></script>
</head>

<body>
    <table width="600" border="1" cellpadding="0" cellspacing="0">
        <caption>课程表</caption>
        <tr>
            <th>节次\日期</th>
            <th>星期一</th>
            <th>星期二</th>
            <th>星期三</th>
            <th>星期四</th>
            <th>星期五</th>
        </tr>
        <tr>
            <td>第12节</td>
            <td>体育</td>
            <td>大学英语</td>
            <td>高等数学</td>
            <td colspan="2" align="center">数据结构</td>
        </tr>
        <tr>
            <td id="a1">第34节</td>
            <td>大学英语</td>
            <td>高等数学</td>
            <td>数据结构</td>
            <td>Web开发实验</td>
            <td>Web开发实验</td>
        </tr>
        <tr align="center">
            <td colspan="6">使用时间:2025第一学期</td>
        </tr>
    </table>
    <script>
        // document.getElementById("a1").style.backgroundColor="#ccc"

        // 页面一开始就加载
        //window.onload = function () {
            let trs = document.getElementsByTagName("tr");
            for (let i = 0; i <= trs.length; i++) {
                if (i % 2 == 0) {  //i偶数,奇数行===0开始索引
                    let obj = trs[i];
                    obj.style.backgroundColor = "#ccc"

                }
            }
      //  }

    </script>
    <script>
        $(document).ready(function(){
            $("tr:even").css("background-color","red")
        })


    </script>

</body>

</html>